package com.novel.authorization.staff.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.novel.authorization.staff.entity.NfGroup;
import com.novel.authorization.staff.mapper.NfGroupMapper;
import com.novel.authorization.staff.service.NfGroupService;
import com.novel.authorization.staff.vo.GroupVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * 角色表
 *
 * @author 樊温军
 * @date Wed May 07 10:50:33 CST 2025
 */
@Slf4j
@Service
@AllArgsConstructor
public class NfGroupServiceImpl extends ServiceImpl<NfGroupMapper, NfGroup> implements NfGroupService {

    @Override
    public List<NfGroup> getNfGroupList(NfGroup nfGroup) {
        return baseMapper.getList(nfGroup);
    }

    @Override
    public IPage<NfGroup> getPage(Page<NfGroup> page, NfGroup nfGroup) {
        return baseMapper.getPage(page, nfGroup);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long saveOneNfGroup(NfGroup nfGroup) {
        this.saveOrUpdate(nfGroup);
        return nfGroup.getId();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delById(Long id) {
        baseMapper.delete(Wrappers.<NfGroup>query().lambda().in(NfGroup::getId, id));
    }

    @Override
    public List<String> getPermissionList(Object loginId) {
        return baseMapper.getPermissionList(loginId);
    }

    @Override
    public List<String> getRoleList(Object loginId) {
        return baseMapper.getRoleList(loginId);
    }

    @Override
    public List<GroupVO> getGroupList(Long userId) {
        return baseMapper.getGroupList(userId);
    }

    @Override
    public NfGroup queryById(Long id) {
        return baseMapper.selectById(id);
    }
}
